Plotly

Plotly is a free and open-source graphing library for Python.

Installation

plotly may be installed using pip

cmd
pip install plotly

or conda.

cmd
conda install -c plotly plotly

Note: No internet connection, account, or payment is required to use plotly.py. Prior to version 4, this library could operate in either an "online" or "offline" mode. The documentation tended to emphasize the online mode, where graphs get published to the Chart Studio web service. In version 4, all "online" functionality was removed from the plotly package and is now available as the separate, optional, chart-studio package (See below). plotly.py version 4 is "offline" only, and does not include any functionality for uploading figures or data to cloud services.

Note: Make sure you only have one installation of Python on your computer when you do this, otherwise the installation may not work.

18.3.2 Jupyter Notebook Installation (Additional)

Note: If you already have anaconda installed or juputer notebook installed no need to install it again, but check with the specified version also.

For use in the classic Jupyter Notebook, install the notebook and ipywidgets packages using pip.

cmd
pip install "notebook>=5.3" "ipywidgets>=7.2"

or conda.

cmd
conda install "notebook>=5.3" "ipywidgets>=7.2"

These packages contain everything you need to run a Jupyter notebook.

jupyter notebook

and display plotly figures inline using the notebook renderer.

18.3.3 JupyterLab Installation (Python 3.5+)

For use in JupyterLab, install the jupyterlab and ipywidgets packages using pip.

cmd
pip install jupyterlab "ipywidgets>=7.5"

or conda.

cmd
conda install jupyterlab "ipywidgets=7.5"

Then run the following commands to install the required JupyterLab extensions (note that this will require node to be installed):

JupyterLab renderer support

cmd
jupyter labextension install jupyterlab-plotly@4.9.0

OPTIONAL: Jupyter widgets extension

cmd
jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.9.0

These packages contain everything you need to run JupyterLab

cmd
jupyter lab

and display plotly figures inline using the plotly_mimetype renderer.

18.3.4 Plotly Express in Python

Plotly Express is a terse, consistent, high-level API for creating figures.

Plotly Express currently includes the following functions:

1) Basics: scatter, line, area, bar, funnel, timeline
2) Part-of-Whole: pie, sunburst, treemap, funnel_area
3) 1D Distributions: histogram, box, violin, strip
4) 2D Distributions: density_heatmap, density_contour
5) Matrix Input: imshow
6) 3-Dimensional: scatter_3d, line_3d
7) Multidimensional: scatter_matrix, parallel_coordinates, parallel_categories
8) Tile Maps: scatter_mapbox, line_mapbox, choropleth_mapbox, density_mapbox
9) Outline Maps: scatter_geo, line_geo, choropleth
10) Polar Charts: scatter_polar, line_polar, bar_polar
11) Ternary Charts: scatter_ternary, line_ternary

The following set of figures is just a sampling of what can be done with Plotly Express.

18.3.4.1 Scatter, Line, Area and Bar Charts

More Details of parallel coordinates and parallel categories

18.3.4.2 Whole Charts

18.3.4.3 1D Distributions

18.3.4.4 2D Distributions

18.3.4.5 Images and Heatmaps

18.3.4.6 3D Coordinates

18.3.5.7 Tile maps and point on tile maps.

18.3.5.8 Polar Coordinates

18.3.4.8 Ternary Coordinates

Ternary chart info